<!--
 * @Author: ac98l
 * @Date: 2023-03-08 08:52:23
 * @LastEditors: ac98l
 * @LastEditTime: 2023-03-08 09:48:55
 * @Description:
-->
<template>
  <div class="app-container ">
    <el-table :data="tableData" border style="width: 100%" :max-height="tableHeight" :height="tableHeight" v-loading="tableLoading">
      <el-table-column prop="username" label="外卖员名称" width="130" show-overflow-tooltip align="center">
      </el-table-column>
      <el-table-column prop="phonenumber" label="外卖员手机号" width="110" align="center">
      </el-table-column>
      <el-table-column prop="commodity" label="商品名称" show-overflow-tooltip min-width="200px" align="center">
      </el-table-column>
      <el-table-column label="商品图片" width="122px" align="center">
        <template slot-scope="scope">
          <viewer>
            <img :src="scope.row.picture" style="width:80px;height: 70px;cursor:pointer ">
          </viewer>
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="下单时间" show-overflow-tooltip width="170px" align="center">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getDeliver } from "@/api/delivery"
export default {
  data() {
    return {
      tableHeight: 200,
      tableData: [],
      tableLoading: false
    }
  },
  // username：外卖员名称  phonenumber：外卖员手机号 commodity：商品名称 totalAmount：商品金额。picture： 图片 createTime：下单时间
  created() {
    this.tableLoading = true
    getDeliver().then(res => {
      this.tableData = res.data
      this.tableLoading = false
    })
  },
  mounted() {
    //以下高宽 兼容所有浏览器 显示浏览器窗口的高度和宽度：（不包括工具栏/滚动条）
    //宽度
    //var w=window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    //高度
    var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
    this.$nextTick(function () {
      this.tableHeight = h - 210
      // 监听窗口大小变化
      let self = this
      window.onresize = function () {
        self.tableHeight = h - 210
      }
    })
  },

  destroyed() {
    window.onresize = null
  }
}
</script>